<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
 

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/template/modal/css/bootstrap.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="<?php echo base_url();?>assets/template/modal/js/bootstrap.min.js"></script>
 </head>
 <body>
<?php $i=1;?>
<?php foreach($request_of_works as $row):?>

		<?php $idThread= $row['id_sd_thread']; ?>
		<?php $idProject= $row['id_project_parent']; ?>
		<?php $approved_by_konsultan= $row['approved_by_konsultan']; ?>
		<?php $approved_by_mp= $row['approved_by_mp']; ?>
	<table border=1 class="table table-bordered">
		<tr>
			<td colspan="6">REQUEST OF WORK</td>
		</tr>
		<tr>
			<td colspan="6">TO :  <?php echo $row['kepada'];?></td>
		</tr>
		<tr>
			<td>Pay Item</td>
			<td>Kind Of Work</td>
			<td>Unit</td>
			<td>Total Estimate Quantity</td>
			<td>Location</td>
			<td>Time For Inspection</td>
		</tr>
		<?php foreach($row_details as $row_detail):?>
		<tr>
			<td><?php echo $row_detail['no_pay_item']?></td>
			<td><?php echo $row_detail['kind_of_work']?></td>
			<td><?php echo $row_detail['unit']?></td>
			<td><?php echo $row_detail['quantity']?></td>
			<td><?php echo $row_detail['location']?></td>
			<td><?php echo date('d-m-Y', strtotime($row_detail['time_inspection']));?></td>
		</tr>
		<?php $i++;endforeach; ?>
		<tr>
			<td colspan="1">REQUEST BY : <br/><br/><br/><br/><br/><hr>--/--/-- Contractor</td>
			<td colspan="1">INSPECTED BY : <br/><br/><br/><br/><br/><hr>--/--/-- Inspector</td>
			<td colspan="2">CHECKED BY : <br/><br/><br/><br/><br/><hr>--/--/-- Chief Inspector Engineer</td>
			<td colspan="2">APPROVED BY : <br/><br/><br/><br/><br/><hr>--/--/-- Divisi Pelaksanaan</td>
		</tr>
<?php endforeach; ?>
	</table>
	<?php
	if($this->session->userdata('level')==3 AND $approved_by_konsultan=="")
	{
	?>
	<form method="post" action="<?php echo base_url();?>index.php/project/approveROW" enctype="multipart/form-data">
	<button class="btn btn-success">
		Accept
    </button>
	<input type="hidden" name="idROW" value="<?php echo $idROW;?>">
	<input type="hidden" name="idThread" value="<?php echo $idThread;?>">
	<input type="hidden" name="status" value="ACCEPT">
	<button class="btn btn-success" data-toggle="modal" data-target="#myModal">
      Reject
    </button>
	</form>
	
		  <form method="post" action="<?php echo base_url();?>index.php/project/rejectROW" enctype="multipart/form-data">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel">Request Of Work Comment</h4>
          </div>
          <div class="modal-body">
		  <textarea class="form-control" name="komentar" rows="3"></textarea>
		  <input type="hidden" name="idROW" value="<?php echo $idROW;?>">
		  <input type="hidden" name="status" value="REJECT">
		  
	<input type="hidden" name="idThread" value="<?php echo $idThread;?>">
          </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
            <button type="submit" class="btn btn-primary">Simpan</button>
          </div>
		 
        </div>
      </div>
    </div>
	 </form>
	<?php
	}
	elseif($this->session->userdata('level')==4 AND $approved_by_konsultan=="ACCEPT" AND $approved_by_mp=="")
	{
	?>
	<form method="post" action="<?php echo base_url();?>index.php/project/approveROW" enctype="multipart/form-data">
	<button class="btn btn-success">
		Accept
    </button>
	<input type="hidden" name="idROW" value="<?php echo $idROW;?>">
	<input type="hidden" name="idThread" value="<?php echo $idThread;?>">
	<input type="hidden" name="status" value="ACCEPT">
	<button class="btn btn-success" data-toggle="modal" data-target="#myModal">
      Reject
    </button>
	</form>
	
		  <form method="post" action="<?php echo base_url();?>index.php/project/rejectROW" enctype="multipart/form-data">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel">Request Of Work Comment</h4>
          </div>
          <div class="modal-body">
		  <textarea class="form-control" name="komentar" rows="3"></textarea>
		  <input type="hidden" name="idROW" value="<?php echo $idROW;?>">
		  <input type="hidden" name="status" value="REJECT">
		  
	<input type="hidden" name="idThread" value="<?php echo $idThread;?>">
          </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
            <button type="submit" class="btn btn-primary">Simpan</button>
          </div>
		 
        </div>
      </div>
    </div>
	 </form>
	<?php
	}
	elseif($approved_by_konsultan=="ACCEPT" AND $approved_by_mp=="ACCEPT")
	{
	?>
	<blockquote>
  <p>Request Of Work Telah Di Setujui.</p>
</blockquote>
	<?php
	}
	elseif($approved_by_konsultan=="REJECT" OR $approved_by_mp=="REJECT")
	{
	?>
	<a href="<?php echo base_url();?>index.php/project/formROW/<?php echo $idThread;?>/<?php echo $idProject;?>"><i class="btn btn-default btn-rounded">Upload Request Of Work</i></a>
	<?php
	}
	?>
  </body>
</html>